package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Supplier;
import cn.wolfcode.crm.mapper.SupplierMapper;
import cn.wolfcode.crm.service.ISupplierService;
import cn.wolfcode.crm.util.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import org.omg.PortableInterceptor.SUCCESSFUL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements ISupplierService{

    @Autowired
    private SupplierMapper supplierMapper;


    public PageResult queryForList(QueryObject qo) {
        List<Supplier> list = supplierMapper.queryForList(qo);
        return new PageResult(list.size(),list);
    }

    public List<Supplier> list() {
        List<Supplier> list = supplierMapper.selectAll();
        return list;
    }

    public void save(Supplier supplier) {
        supplierMapper.insert(supplier);
    }

    public void update(Supplier supplier) {
        supplierMapper.updateByPrimaryKey(supplier);
    }

    public void delete(Long id) {
        if(id != null){
            supplierMapper.deleteByPrimaryKey(id);
        }
    }
}
